package com.fresh.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.fresh.entity.CaiGou;
import com.fresh.entity.CaiGouQO;
import com.fresh.mapper.CaiGouMapper;
import com.fresh.service.CaiGouService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CaiGouServiceImpl implements CaiGouService {
    @Autowired
    CaiGouMapper caiGouMapper;

    @Override
    public PageInfo<CaiGou> findPageInfoByCondition(CaiGouQO caiGouQO, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<CaiGou> caiGous = caiGouMapper.findPageInfoByCondition(caiGouQO);
        PageInfo<CaiGou> pageInfo = new PageInfo<>(caiGous);
        return pageInfo;
    }

    @Override
    public void add(CaiGou caiGou) {
        caiGouMapper.insert(caiGou);
    }

    @Override
    public void update(CaiGou caiGou) {
        caiGouMapper.update(caiGou);
    }

    @Override
    public void changeStatus3ByCgNo(String cgNo,String data) {
        caiGouMapper.updateStatus3ByCgNo(cgNo,data);
    }

}
